<?php


namespace app\admin\controller\manage;


use app\common\Common;
use app\sys\model\Fun;
use think\Request;
use app\sys\model\Role as RoleModel;

class Role extends Common
{
    // 数据列表
    public static function roleDutyList()
    {
        $list = RoleModel::list();
        return successJson("success",$list);
    }

    // 权限
    public static function roleList(Request $request)
    {
        $dutyId = $request->param("duty_id",0);
        $isData = $request->param("is_data",0);
        $isDataStatus = $request->param("is_data_status",0);

        $list = Fun::list($dutyId,$isData,$isDataStatus);
        return successJson("success",$list);
    }

    // 权限
    public static function roleListData(Request $request)
    {
        $dutyId = $request->param("duty_id",0);
        $isData = $request->param("is_data",0);
        $isDataStatus = $request->param("is_data_status",0);
        $info = $request->_user;
        $list = Fun::listData($dutyId,$info["staff_no"],$isData,$isDataStatus);
        return successJson("success",$list);
    }

    // 权限
    public static function roleListDataUrl(Request $request)
    {
        $info = $request->_user;
        $list = Fun::listDataUrl($info["staff_no"],$info["duty_id"]);
        return successJson("success",$list);
    }

    // 权限添加
    public static function addRole(Request $request)
    {
        $dutyId = $request->param("duty_id",0);
        $roleArr = $request->param("role_arr",[]);
        $res = RoleModel::RoleSave($dutyId,$roleArr);
        if($res)return failedJson($res);
        return successJson("success","成功");
    }

}